export default{
	// 区间
	time_section(time_list){
		let m2h = time_list[3] + ":" + time_list[4]
		// 上午或凌晨
		if(time_list[3]<12){
			if(time_list[3]==6){
				return '晚上 ' + m2h
			}
			return time_list[3]>=7 ? '上午 '+ m2h : '凌晨 ' + m2h
		}
		// 中午或下午
		else if(time_list[3]<18){
			return time_list[3]>=13 ? '下午 ' + m2h : '中午 ' + m2h
		}else{
			return '晚上 ' + m2h
		}
	},
	disabledDate(time,pretime=null){
		let times = new Date(time).getTime()
		let pretimes = new Date(pretime).getTime()
		if(times-pretimes >= 0 && times-pretimes < 300000){
			return false
		}
		let time_now = new Date()
		let year = time_now.getFullYear()
		let month = time_now.getMonth() + 1 
		let data = time_now.getDate()
		let time_list = new Date(+times + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '').replace(/-/gi,' ').replace(/:/g,' ').split(" ")
		let m2d = time_list[1] + '月' + time_list[2] + '日 '
		let y2m2d = time_list[0] +'年' + m2d
		let time_section = this.time_section(time_list)
		let time_dict= {
			key:time_section,
			value:time_section
		}
		
		// ["2021", "07", "18", "22", "23", "04"]
		if(year-time_list[0]){
			time_dict.key = y2m2d
			return time_dict
		}
		let days = new Date(time).getDay()
		// 小于当前月或者等于当前月并且大于七天的评论
		if(month-time_list[1] || (time_list[1] == month&&data-time_list[2]>=7)){
			time_dict.key = m2d
			return time_dict
		}
		// 在这个星期之内
		if(data-time_list[2]>1){
			let day_list={1:'一 ',2:'二 ',3:'三 ',4:'四 ',5:'五 ',6:'六 '}
			let now_day = time_now.getDay()
			// 今天是否已经为第二个星期
			if((days>=now_day && now_day!=0)||!days){
				time_dict.key = m2d		
			}else{
				time_dict.key = '星期'+day_list[days]
			}			
			return time_dict
		}
		// 今天的时间
		if(data-time_list[2]==0){
			time_dict.value = ''

			return time_dict
		}
		
		time_dict.key = '昨天 '
		return time_dict
		 
	},
	// 计算当前日期星座
	getHoroscope(date) {
	  let c = ['摩羯','水瓶','双鱼','白羊','金牛','双子','巨蟹','狮子','处女','天秤','天蝎','射手','摩羯']
	  date=new Date(date);
	  let month = date.getMonth() + 1;
	  let day = date.getDate();
	  let startMonth = month - (day - 14 < '865778999988'.charAt(month));
	  return c[startMonth]+'座';
	},
	// 计算年龄
	age_datetime(value){
		
		if(value==="保密" ||value==="" ){
			return "保密"
		}
		// 毫秒转化年
		let n = 3.1710e-11
		let stamp=new Date()-new Date(value)
		
		let age = stamp*n 
		return Math.floor(age)
	}		

}